<?php

namespace App\Models\Goods;

use Illuminate\Database\Eloquent\Model;

class Goods extends Model
{
    /**
     * 关联到模型的数据表
     *
     * @var string
     */
    protected $table = 'goods';

    public static function getGoodsByGoodsId($goods_id){
        $goods = self::where(['id'=>$goods_id,'status'=>1])->first()->toArray();
        return $goods ?? [] ;
    }

    public static function getAllGoods($catid){
        $goods = self::where(['status'=>1,'category_id'=>$catid])->get()->toArray();
        return $goods ?? [] ;
    }

    public static function getGoodsByCategoryid($catid,$field){
        $goods = self::where(['status'=>1,'category_id'=>$catid])->orderBy('id','desc')->paginate(6);
        return $goods  ;
    }


}
